package networkTraining.inspection;

import networkTraining.epoch.IEpochExecutor;
import neuralModel.neuron.INeuron;
import neuralModel.neuron.ISignal;
import neuralNetwork.INeuralNetwork;

public class SingleNeuronWeightInspector implements IPreInitializeInspector, IPostTrainingEpochInspector
{
	private INeuron neuron;
	private StringBuilder neuronWeightInfo;

	public SingleNeuronWeightInspector(INeuron neuron)
	{
		this.neuron = neuron;
		neuronWeightInfo = new StringBuilder();
	}

	@Override
	public void preInitializeInspect(INeuralNetwork neuralNetwork)
	{
		neuronWeightInfo.append(String.format("Neuron: %s\n\n", neuron.getName()));

		for (ISignal signal : neuron.getInputSignalList())
		{
			neuronWeightInfo.append(String.format("%10s-Weight\t", signal.getSourceNeuron().getName()));
		}
		neuronWeightInfo.append("\n");

		for (ISignal signal : neuron.getInputSignalList())
		{
			neuronWeightInfo.append(String.format("%17f\t", signal.getWeight()));
		}
		neuronWeightInfo.append("\n");
	}

	@Override
	public void postEpochInspect(IEpochExecutor epochExecutor)
	{
		for (ISignal signal : neuron.getInputSignalList())
		{
			neuronWeightInfo.append(String.format("%17f\t", signal.getWeight()));
		}
		neuronWeightInfo.append("\n");
	}

	public String getInspectionInfo()
	{
		return neuronWeightInfo.toString();
	}

}
